﻿@model Leads360Express.Repository.Pages.Lead.LeadModel

@{
    ViewBag.Title = "View Lead Result - Standard View";
    Layout = "~/Views/Shared/_Layout.Lead.cshtml";
}

@section DataBinding
{    
    <script type="text/javascript">
        var data = @(Html.Raw(Json.Encode(Model)));
    </script>
    <script src="/Scripts/viewModel/viewmodel.leadresult.js" type="text/javascript"></script>
    
    <script type="text/javascript">
        $('.no-count').tooltip({
            showURL: false,
            track: true,
            fade: 150,
            top: -40,
            left: -100
        }).css('cursor', 'pointer');
        $('#tooltip').addClass('bold').css('padding', '0px');
  </script>
}

<form class="form" action="#" id="viewLeads">
    <fieldset id="searchLeadResult">						
        <div class="content">
	        <h2 class="app">
		        <span class="viewtitle"><strong>Find Leads</strong></span>
	        </h2>
                
            <div class="title nomargin">
		        <h3>Lead Results</h3>
	        </div>            
            <span class="paging" data-bind="visible: Leads().length > 0">
                <span class="pageleft">                
                    <span class="total" data-bind='text: PageText'></span>
                    <span class="show ">Show <input type="text" class="text" id="pagesize" data-bind='value: PageSize, attr: {maxlength: 3}' /> per page <span class="smallText" data-bind="text: PageSizeText"></span> </span>
                </span>
                <span class="pages">
                    <span class="smallText" data-bind="text: PageCurrentText"></span>Page <input type="text" class="text" id="pagecurrent" data-bind='value: CurrentPageIndex, enable: Leads().length>0' /> of <span data-bind='text: MaxPageIndex' class="totalpages"></span>
                    <a href="#" data-bind="click: PrevPage, attr: {'class': PrevButtonClass}">Prev </a>
  		            <a href="#" data-bind="click: NextPage, attr: {'class': NextButtonClass}">Next </a>
                </span>
            </span>

                <div id="gridLead" class="table table-leads" data-bind="visible: Leads().length > 0">
                    <div class="title" >
                        <div class="col1" data-bind='click: function(event) { SetOrder(event, "Name")}'>
                            <span class="w" style="height:22px">
                                <a href="#">Name</a>
                                <div class="sort_wrapper" id="Name">  
                                    <span class="grid_order ui_icon"></span>
                                </div>                                        
                            </span>                          
                        </div>
			            <div class="col1 col2" data-bind='click: function(event) { SetOrder(event, "Phone")}'>
                            <span class="w" style="height:22px">
                                <a href="#">Phone</a>
                                <div class="sort_wrapper" id="Phone">  
                                    <span class="grid_order ui_icon"></span>
                                </div>              
                            </span>
                        </div>
			            <div class="col1 col3" data-bind='click: function(event) { SetOrder(event, "Email")}'>
                            <span class="w" style="height:22px">
                                <a href="#">Email</a>
                                <div class="sort_wrapper" id="Email">  
                                    <span class="grid_order ui_icon"></span>
                                </div>              
                            </span>
                        </div>
			            <div class="col1 col4" data-bind='click: function(event) { SetOrder(event, "DateAdded")}'>
                            <span class="w" style="height:22px">
                                <a href="#">Date Added</a>
                                <div class="sort_wrapper" id="DateAdded">  
                                    <span class="grid_order ui_icon desc"></span>
                                </div>              
                            </span>
                        </div>
			            <div class="col1 col5" data-bind='click: function(event) { SetOrder(event, "LastAction")}'>
                            <span class="w" style="height:22px">
                                <a href="#">Last Action</a>
                                <div class="sort_wrapper" id="LastAction">  
                                    <span class="grid_order ui_icon"></span>
                                </div>              
                            </span>
                        </div>
			            <div class="col1 col6" data-bind='click: function(event) { SetOrder(event, "Status")}'>
                            <span class="w" style="height:22px">
                                <a href="#">Status</a>
                                <div class="sort_wrapper" id="Status">  
                                    <span class="grid_order ui_icon"></span>
                                </div>              
                            </span>
                        </div>
			            <div class="col1 col7"><span class="w" style="height:22px">Quick Action</span></div>
			            <div class="col1 col8" data-bind='click: function(event) { SetOrder(event, "UserName")}, visible: VisibleUserColumn'>
                            <span class="w" style="height:22px">
                                <a href="#">User</a>
                                <div class="sort_wrapper" id="UserName">  
                                    <span class="grid_order ui_icon"></span>
                                </div>              
                            </span>
                        </div>
			            <div class="col1 col9">
                            <span class="w" style="height:22px" data-bind="text: FieldName1">          
                            </span>
                        </div>
			            <div class="col1 col10">
                            <span class="w" style="height:22px" data-bind="text: FieldName2">            
                            </span>
                        </div>
			            <div class="col1 col11"><span class="w" style="height:22px">Action Count</span></div>
			            <div class="col1 col12 centeralign"><span class="w" style="height:22px">Delete</span></div>
                    </div>
                    <div class="linegroup" data-bind="foreach: Leads " >
                        <div class="line" data-bind="attr:{'class': $root.LineClass($index(), $parent.Leads().length - 1, StatusType)}">                        
			                <div class="col1"><span class="w" style="min-height: 24px;"><a data-bind='text: ShortName, attr: {href: "/Lead/Edit/" + LeadEdit, title: Name}'></a></span></div>
			                <div class="col1 col2">
                                <span class="w" style="min-height: 24px;">
                                    <a href="##" class="button" data-bind='visible: ShowPhoneLink, text: ShortPhone, attr: {title: Phone, onclick: "dialIDCallPhone(" + Leadid + ")", id: "callphone_" + Leadid, rel: Phone}'></a>
                                    <span  data-bind='visible: !ShowPhoneLink, text: ShortPhone, attr: {title: Phone}'></span>
                                </span>
                            </div>
			                <div class="col1 col3">
                                <span class="w" style="min-height: 24px;">
                                    <a data-bind='visible: ShowEmailLink, text: ShortEmail, attr: {title: Email, href: "mailto:" + Email}'></a>
                                    <span  data-bind='visible: !ShowEmailLink, text: ShortEmail, attr: {title: Email}'></span>
                                </span>
                            </div>
			                <div class="col1 col4"><span class="w" style="min-height: 24px;" data-bind='text: DateAdded,attr: {title: DateAdded}'></span></div>
			                <div class="col1 col5"><span class="w" style="min-height: 24px;" data-bind='text: LastAction,attr: {title: LastAction}'></span></div>
			                <div class="col1 col6"><span class="w" style="min-height: 24px;"><span class="green" data-bind='text: ShortStatus, attr: {title: Status, "style": "color: " + Color}'></span></span></div>
			                <div class="col1 col7"><span class="w" style="min-height: 24px;"><a href="#" data-bind='text: ShortQuickaction, click: $parent.ButtonQickAction, attr: {title: QuickAction}'></a></span></div>
			                @*<div class="col1 col8" data-bind="visible: UserVisible">
                                <span class="w" style="min-height: 24px;">
                                    <a data-bind='text: ShortUserName, attr: {href: "javascript:setUserName(" + Leadid + ")", id: "user-lead" + Leadid, title: UserName, rel: Name}'></a>
                                </span>
                            </div>*@
                            <div class="col1 col8" data-bind="visible: UserVisible">
                                <span class="w" style="min-height: 24px;">
                                    <a data-bind='text: ShortUserName, attr: {href: "javascript:void(0)", id: "user-lead" + Leadid, title: UserName, rel: Name, onclick: "reasignOpen(" + Leadid + ", " + UserId + ")"}'></a>
                                </span>
                            </div>

			                <div class="col1 col9"><span class="w" style="min-height: 24px;" data-bind='text: ShortVM1, attr: {title: Vm1}'></span></div>
			                <div class="col1 col10"><span class="w" style="min-height: 24px;" data-bind='text: ShortVM2, attr: {title: Vm2}'></span></div>
			                
			                <div class="col1 col11 count-tooltip" style="cursor: pointer;" data-bind="visible: (ActionCount  != '0')">
                                <span class="w" style="min-height: 24px;" data-bind='text: ActionCount'></span>   
                                
                                <!-- loop tooltip -->
                                <div class="tooltip-content">
        							<div class="table tooltip-simpletable">
        								<div class="title">
        									<div class="col1">Last 5 Actions</div>
        									<div class="col1 col2">User</div>
        									<div class="col1 col3">Date &amp; Time</div>
        								</div>

                                        <div class="linetip" data-bind="foreach: ActionLog">                                        
                                            <div class="line">
        									    <div class="col1" data-bind="text: ActionTypeName"></div>
        									    <div class="col1 col2" data-bind="text: UserName"></div>
        									    <div class="col1 col3" style="border-right: medium none;" data-bind="text: ActionDate"></div>
        								    </div>
                                        </div>
        							</div>
        						</div>                            
                            </div>
                            <div class="col1 col11 no-count" style="cursor: pointer;" data-bind="visible: (ActionCount == '0')" title="This lead has no actions">
                                <span class="w" style="min-height: 24px;" data-bind="text: ActionCount">0</span>
                            </div>

                            <div class="col1 col12 centeralign" data-bind="attr:{'class': ($index() === ($parent.Leads().length - 1))? 'col1 col12 centeralign btm': 'col1 col12 centeralign'}"><span class="w" style="min-height: 24px;"><a class="btn btn-x" data-bind='visible: UserVisible, attr: {id: "lead" + Leadid, href: "javascript:void(0)", rel: Name, onclick: "confirmPopup(" + Leadid + ")"}' >Delete</a></span></div>
                        </div>
                    </div>
                </div>   
                <div class="panel" data-bind="visible: Leads().length<=0">
                    <div class="error-msg" ><span>No results were found.</span></div>                        
                </div>
               <div class="clear"></div>                               
           
             
               @Html.Partial("_Footer.Copyright")
        </div>   
    </fieldset>  

    @Html.Partial("_PopupAssignLeadToUser")
    @Html.Partial("_PopupModelDelete")
    @Html.Partial("_PartialDialError")
</form>       
